package com.fit.entities.user;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.apache.tapestry5.beaneditor.NonVisual;
import org.hibernate.annotations.NaturalId;

import com.fit.dao.homeworkRecords.HomeworkRecordsDAOImpl;
import com.fit.entities.homeworkRecords.HomeworkRecords;
import com.fit.entities.studentOfTheCourse.StudentOfTheCourse;
import com.fit.model.UserRole;

@Entity
@Table(name = "users")
public class User {
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@NonVisual
	@Column(name = "user_id")
	private Long id;
	@NaturalId
	@Column(nullable = false, unique = true, name = "username")
	@NotNull
	private String userName;
	@Column(nullable = false)
	@NotNull
	private String fullname;
	@Column(nullable = false)
	@Size(min = 3, max = 70)
	@NotNull
	private String email;
	@Column(nullable = true)
	@Size(min = 3, max = 70)
	private String education;
	@Column(nullable = true)
	@Size(min = 3, max = 70)
	private String numberOfIndex;
	@Column(nullable = true)
	private Date yearOfEnrollment;
	@Column(nullable = false)
	@NotNull
	private String password;
	@Column(nullable = false, name = "role")
	private UserRole role;



	public UserRole getRole() {
		return role;
	}

	public void setRole(UserRole role) {
		this.role = role;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String username) {
		this.userName = username;
	}

	public String getFullname() {
		return fullname;
	}

	public void setFullname(String fullname) {
		this.fullname = fullname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	

	public String getEducation() {
		return education;
	}

	public void setEducation(String education) {
		this.education = education;
	}

	public String getNumberOfIndex() {
		return numberOfIndex;
	}

	public void setNumberOfIndex(String numberOfIndex) {
		this.numberOfIndex = numberOfIndex;
	}

	public Date getYearOfEnrollment() {
		return yearOfEnrollment;
	}

	public void setYearOfEnrollment(Date yearOfEnrollment) {
		this.yearOfEnrollment = yearOfEnrollment;
	}

	public boolean isAdmin() {
		if (role == UserRole.ADMIN) {
			return true;
		}
		return false;
	}

	public boolean isProfessor() {
		if (role == UserRole.PROFESSOR) {
			return true;
		}
		return false;
	}
	public boolean isStudent() {
		if (role == UserRole.STUDENT) {
			return true;
		}
		return false;
	}



}
